package com.cole.gx095.entity;

import com.cole.gx095.domain.CostVo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
@EntityListeners(AuditingEntityListener.class)
@JsonIgnoreProperties(value = { "hibernateLazyInitializer"})
@Table(name = "salecontract")
public class Salecontract {
    @Transient
    private List<CostVo> costVoList = new ArrayList<>();

    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Id
    @Column(name = "Id")
    private int id;
    /**
     *  合同所属姓名id
     */
    @Basic
    @Column(name = "SalespersonId")
    private Integer salespersonId;
    /**
     *  合同所属姓名
     */
    @Basic
    @Column(name = "SalespersonName")
    private String salespersonName;
    @Basic
    @Column(name = "ContractNum")
    private String contractNum;
    @Column(name = "ContractDate")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
    private Date contractDate;
    /**
     * 采购单位
     */
    @Basic
    @Column(name = "BuyUnit")
    private String buyUnit;
    /**
     * 合同金额
     */
    @Basic
    @Column(name = "ContractAmount")
    private Double contractAmount;
    /**
     * 关联金额
     */
    @Basic
    @Column(name = "CorrelationAmount")
    private Double correlationAmount;
    /**
     * 关联率
     */
    @Basic
    @Column(name = "CorrelationRate")
    private Double correlationRate;
    /**
     * 关联地区 无效字段
     */
    @Basic
    @Column(name = "CorrelationState")
    private Integer correlationState;
    @Basic
    @Column(name = "AttachCount")
    private Integer attachCount;
    @Basic
    @Column(name = "UpdateCount")
    private Integer updateCount;
    @Basic
    @Column(name = "CreateAdminTrueName")
    private String createAdminTrueName;
    @Basic
    @CreatedDate
    @Column(name = "CreateDate")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Timestamp createDate;
    @Basic
    @Column(name = "BillCount")
    private Integer billCount;
    /**
     * 发票金额
     */
    @Basic
    @Column(name = "BillAmount")
    private Double billAmount;
    /**
     * 0未开票 1部分开票 2已开票
     */
    @Basic
    @Column(name = "BillStatus")
    private Integer billStatus;
    /**
     * 0待完成 1已完成
     */
    @Basic
    @Column(name = "Status")
    private Integer status;
    @Basic
    @Column(name = "Remarks")
    private String remarks;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public Integer getSalespersonId() {
        return salespersonId;
    }

    public void setSalespersonId(Integer salespersonId) {
        this.salespersonId = salespersonId;
    }

    public String getSalespersonName() {
        return salespersonName;
    }

    public void setSalespersonName(String salespersonName) {
        this.salespersonName = salespersonName;
    }

    public String getContractNum() {
        return contractNum;
    }

    public void setContractNum(String contractNum) {
        this.contractNum = contractNum;
    }

    public String getBuyUnit() {
        return buyUnit;
    }

    public void setBuyUnit(String buyUnit) {
        this.buyUnit = buyUnit;
    }

    public Double getContractAmount() {
        return contractAmount;
    }

    public void setContractAmount(Double contractAmount) {
        this.contractAmount = contractAmount;
    }

    public Double getCorrelationAmount() {
        return correlationAmount;
    }

    public void setCorrelationAmount(Double correlationAmount) {
        this.correlationAmount = correlationAmount;
    }

    public Double getCorrelationRate() {
        return correlationRate;
    }

    public void setCorrelationRate(Double correlationRate) {
        this.correlationRate = correlationRate;
    }

    public Integer getCorrelationState() {
        return correlationState;
    }

    public void setCorrelationState(Integer correlationState) {
        this.correlationState = correlationState;
    }

    public Integer getAttachCount() {
        return attachCount;
    }

    public void setAttachCount(Integer attachCount) {
        this.attachCount = attachCount;
    }

    public Integer getUpdateCount() {
        return updateCount;
    }

    public void setUpdateCount(Integer updateCount) {
        this.updateCount = updateCount;
    }

    public String getCreateAdminTrueName() {
        return createAdminTrueName;
    }

    public void setCreateAdminTrueName(String createAdminTrueName) {
        this.createAdminTrueName = createAdminTrueName;
    }

    public Timestamp getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Timestamp createDate) {
        this.createDate = createDate;
    }

    public Integer getBillCount() {
        return billCount;
    }

    public void setBillCount(Integer billCount) {
        this.billCount = billCount;
    }

    public Double getBillAmount() {
        return billAmount;
    }

    public void setBillAmount(Double billAmount) {
        this.billAmount = billAmount;
    }

    public Integer getBillStatus() {
        return billStatus;
    }

    public void setBillStatus(Integer billStatus) {
        this.billStatus = billStatus;
    }

    public String getRemarks() {
        return remarks;
    }

    public void setRemarks(String remarks) {
        this.remarks = remarks;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Salecontract that = (Salecontract) o;
        return id == that.id && Objects.equals(salespersonId, that.salespersonId) && Objects.equals(salespersonName, that.salespersonName) && Objects.equals(contractNum, that.contractNum) && Objects.equals(buyUnit, that.buyUnit) && Objects.equals(contractAmount, that.contractAmount) && Objects.equals(correlationAmount, that.correlationAmount) && Objects.equals(correlationRate, that.correlationRate) && Objects.equals(correlationState, that.correlationState) && Objects.equals(attachCount, that.attachCount) && Objects.equals(updateCount, that.updateCount) && Objects.equals(createAdminTrueName, that.createAdminTrueName) && Objects.equals(createDate, that.createDate) && Objects.equals(billCount, that.billCount) && Objects.equals(billAmount, that.billAmount) && Objects.equals(billStatus, that.billStatus) && Objects.equals(remarks, that.remarks);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, salespersonId, salespersonName, contractNum, buyUnit, contractAmount, correlationAmount, correlationRate, correlationState, attachCount, updateCount, createAdminTrueName, createDate, billCount, billAmount, billStatus, remarks);
    }
}
